# -*- coding: utf-8 -*-
# @File  : locustUI.py
# @Author: zbh
# @Date  : 2025/2/20_15:21

from locust import HttpUser, task, between,TaskSet
import os
import time


url = "http://192.168.99.99/acp-custody/rest/login/extend/userForLogin?token=null"
payload = 'loginName=ab&password=HEX-04eea7fe393feb4ef5b3b75468ace6f618c067488e9f90dcaba2da754f5e4493f014789a457b27649c0e39eff5788a312c308db9b94a0d725acad5bc0c14dbf2dbd1e6c9b8300cbe1a3d390666eadc92d6762a8a40e3ec0d9f06577e5379e4058f3f5e1be38a1c2c640989796b61&validType=0&privateKey=ACF40088C2EE020AAFBC396C8131AC6311F57C9608BF1800E9657AF1B6F9C646'
headers = {
  'Content-Type': 'application/x-www-form-urlencoded',
  'Cookie': 'JSESSIONID=0000dHiCmreU0dKYE_Iza1LC-Yb:-1; acp_cookie_name=6E586A70529D27BE63459AB5F76E676234F943CAD98BB64870604F0D'
}

class WebsiteUser(HttpUser):
    host = "http://192.168.99.99"  # host：配置要测试的目标服务器地址，配置后场景事务访问的接口则不需要再添加该地址
    wait_time = between(1, 3)

    @task(1)
    def api1(self):
        self.client.get("/acp-custody/login.html")

    @task(3)   # 表示该任务的执行权重是3，相对于权重低的任务更有可能被执行，不过这只是一个概率上的比例关系；
    def api2(self):
       self.client.post(url, data=payload,headers=headers)

    @task(2)
    def api3(self):
        self.client.get("/acp-custody/view/index.action?token=55B0A16F736D0D3E1E9183D9B5276DEB7A702C0E727A996D1A5C9DB5")


def run():
    os.system("locust -f locustUI.py")

if __name__ == '__main__':
    run()



